New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Pick inner most parse exception as root cause #30270
Conversation
Just like `ElasticsearchException`, the inner most `XContentParseException` tends to contain the root cause of the exception and show be show to the user in the `root_cause` field. The effectively undoes most of the changes that elastic#29373 made to the `root_cause` for parsing exceptions. The `type` field still changes from `parse_exception` to `x_content_parse_exception`, but this seems like a fairly safe change. `ElasticsearchWrapperException` *looks* tempting to implement this but the behavior isn't quite right. `ElasticsearchWrapperExceptions` are entirely unwrapped until the cause no longer `implements ElasticsearchWrapperException` but `XContentParseException` should be unwrapped until its cause is no longer an `XContentParseException` but no further. In other words, `ElasticsearchWrapperException` are unwrapped one step too far. Closes elastic#30261
Pinging @elastic/es-core-infra |
return ((ElasticsearchException) ex).guessRootCauses(); | ||
} | ||
if (ex instanceof XContentParseException) { | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like if we get another exception like this one we should try to build something a little more generic and less "heuristics that make the exception look good". But XContentParseException isn't really the same thing as
ElasticsearchException`. It is similar, but different enough that I don't think I could boil out the generic bits without this getting wonky.
@@ -19,7 +19,11 @@ | |||
|
|||
package org.elasticsearch; | |||
|
|||
/** | |||
* An exception that is meant to be "unwrapped" when sent back to the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one turned out not to be useful but I researched it so I figured I'd add the javadocs.
@@ -124,13 +126,13 @@ public void testGuessRootCause() { | |||
} else { | |||
rootCauses = ElasticsearchException.guessRootCauses(randomBoolean() ? new RemoteTransportException("remoteboom", ex) : ex); | |||
} | |||
assertEquals(ElasticsearchException.getExceptionName(rootCauses[0]), "parsing_exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were all backwards....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for reviewing @dakrone! I've merged and I'll backport now! |
Just like `ElasticsearchException`, the inner most `XContentParseException` tends to contain the root cause of the exception and show be show to the user in the `root_cause` field. The effectively undoes most of the changes that #29373 made to the `root_cause` for parsing exceptions. The `type` field still changes from `parse_exception` to `x_content_parse_exception`, but this seems like a fairly safe change. `ElasticsearchWrapperException` *looks* tempting to implement this but the behavior isn't quite right. `ElasticsearchWrapperExceptions` are entirely unwrapped until the cause no longer `implements ElasticsearchWrapperException` but `XContentParseException` should be unwrapped until its cause is no longer an `XContentParseException` but no further. In other words, `ElasticsearchWrapperException` are unwrapped one step too far. Closes #30261
Just like `ElasticsearchException`, the inner most `XContentParseException` tends to contain the root cause of the exception and show be show to the user in the `root_cause` field. The effectively undoes most of the changes that #29373 made to the `root_cause` for parsing exceptions. The `type` field still changes from `parse_exception` to `x_content_parse_exception`, but this seems like a fairly safe change. `ElasticsearchWrapperException` *looks* tempting to implement this but the behavior isn't quite right. `ElasticsearchWrapperExceptions` are entirely unwrapped until the cause no longer `implements ElasticsearchWrapperException` but `XContentParseException` should be unwrapped until its cause is no longer an `XContentParseException` but no further. In other words, `ElasticsearchWrapperException` are unwrapped one step too far. Closes #30261
Just like
ElasticsearchException
, the inner mostXContentParseException
tends to contain the root cause of theexception and show be show to the user in the
root_cause
field.The effectively undoes most of the changes that #29373 made to the
root_cause
for parsing exceptions. Thetype
field still changes fromparse_exception
tox_content_parse_exception
, but this seems like afairly safe change.
ElasticsearchWrapperException
looks tempting to implement this butthe behavior isn't quite right.
ElasticsearchWrapperExceptions
areentirely unwrapped until the cause no longer
implements ElasticsearchWrapperException
butXContentParseException
should be unwrapped until its cause is no longer an
XContentParseException
but no further. In other words,ElasticsearchWrapperException
are unwrapped one step too far.Closes #30261